<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title></title>
    <link rel="stylesheet" href="css/common.css"/>
    <link rel="stylesheet" href="css/login.css"/>
</head>
<script src="js/jquery.min.js"></script>
<script>
    $(function() {
        $("#send").click(function(){
            var name = ($("#login-username").val())
            var pass = ($("#login-password").val())
            var del = ($("#login-del").val())
            // console.log(name)
            // console.log(pass)
            // console.log(del)
            if(name == '' || pass == ''||del == ''){
                alert("请把信息补全")
            }else if(!(/^1[34578]\d{9}$/.test(name))){
                alert("手机号码有误，请重填");
                return false;
            } else {
                var obj = {
                    sendTo: name,
                    courierName: pass,
                    authCode: del
                }
                $.ajax({
                    url: `/SMSPlatform/sendsms`,//?username=${username}&password=${password}`,
                    //url: `http://localhost:8088/SMSPlatform/sendsms`,//?username=${username}&password=${password}`,
                    type: "POST",
                    contentType: "application/x-www-form-urlencoded;charset=utf-8",
                    //data: JSON.stringify(obj),
                    data: obj,
                    dataType: "text",
                    success: function (result) {
                        console.log(result)
                        if (result == 'success') {
                            alert('发送成功');
                            location.reload()
                        } else {
                            alert('发送失败');
                            location.reload();
                        }
                    },
                    error: function (msg) {
                        alert('发送失败');
                }
                }).fail()
            }
        });
    })
</script>

<body>
    <div id="login"></div>
    <div class="login_bg">
        <a style="float: right" href="/SMSPlatform/smslist.html">短信查询</a>
        <!-- <a style="float: right" href="http://localhost:8088/SMSPlatform/smslist.html">短信查询</a>-->
        <div id="logo">
            <div>
                <span>发送短信</span>
            </div>
        </div>
        <form action="">

            <div class="userName">
                <lable>手&nbsp;机&nbsp;号&nbsp;：&nbsp;&nbsp;&nbsp;</lable>
                <input type="text"  id="login-username" name="name" placeholder="请输入手机号" required/>
            </div>
            <div class="passWord">
                <lable>快递名称：&nbsp;&nbsp;&nbsp;</lable>
                <input id="login-password" type="text" name="password" placeholder="请输入快递名称"  required/>
            </div>
            <div class="passWord">
                <lable>取&nbsp;件&nbsp;码&nbsp;：&nbsp;&nbsp;&nbsp;</lable>
                <input id="login-del" type="text" name="password" placeholder="请输入取件码"  required/>
            </div>
            <div class="choose_box">
                <div>
                    <!-- <input type="checkbox" checked="checked" name="checkbox"/>
                    <lable>记住密码</lable> -->
                </div>
                <!-- <a href="newPassword.html">忘记密码</a> -->
            </div>
            <button class="login_btn" id="send" type="button">发&nbsp;&nbsp;送</button>
        </form>

    </div>
</body>

</html>